///import js-src/lib/
///import js-src/com/
qui(function (require, exports, module) {
    Zhibo.Config = $.extend({}, Ancestor.Config, {
        TABLE_COLMODEL_CONFIG: {
            channel_id: {
                name: "channel_id",
                index: 'channel_id',
                width: 120,
                title: false,
                sortable: false,
                hidden: true
            },
            channel_name: {
                name: "channel_name",
                index: 'channel_name',
                title: false,
                width: 120,
                sortable: false
            },
            channel_code: {
                name: "channel_code",
                index: 'channel_code',
                title: false,
                width: 120,
                sortable: false,
                align: "center"
            },
            channel_addr: {
                name: "channel_addr",
                index: 'channel_addr',
                title: false,
                width: 300,
                sortable: false
            },
            channel_ip: {
                name: "channel_ip",
                index: 'channel_ip',
                title: false,
                width: 100,
                sortable: false,
                formatter: function (v, o, r) {
                    return Zhibo.Util.formatter.channel_ip(v, o, r);
                }
            },
            ip: {
                name: "ip",
                index: 'ip',
                title: false,
                width: 100,
                sortable: false
            },
            freeType: {
                name: "freeType",
                index: 'freeType',
                title: false,
                width: 50,
                sortable: false,
                align: "center",
                formatter: function (v, o, r) {
                    return Zhibo.Util.formatter.freeType(v, o, r);
                }
            },
            channel_status: {
                name: "channel_status",
                index: 'channel_status',
                title: false,
                width: 80,
                sortable: false,
                align: "center",
                formatter: function (v, o, r) {
                    return Zhibo.Util.formatter.channel_status(v, o, r);
                }
            },
            operate2: {
                //wait to do
                title: false,
                sortable: false,
                width: 835,
                formatter: function (v, o, r) {
                    return Zhibo.Util.formatter.operate2(v, o, r);
                }
            },
            operate3: {
                title: false,
                sortable: false,
                width: 120,
                formatter: function (v, o, r) {
                    return Zhibo.Util.formatter.operate3(v, o, r);
                }
            },
            region: {
                name: "region",
                index: 'region',
                title: false,
                width: 180,
                sortable: false,
                formatter: function (v, o, r) {
                    return Zhibo.Util.formatter.region(v, o, r);
                }
            },
            location: {
                name: "location",
                index: 'location',
                title: false,
                width: 180,
                sortable: false,
                hidden: true
            },
            loc_id: {
                name: "loc_id",
                index: 'loc_id',
                title: false,
                width: 180,
                sortable: false,
                hidden: true
            },

            log_id: {
                name: 'id',
                index: 'id',
                title: false,
                sortable: false,
                hidden: true
            },
            log_addTime: {
                name: 'addTime',
                index: 'addTime',
                sortable: false,
                title: false,
                width: 150,
                align: 'center'
            },
            log_user: {
                name: 'user',
                index: 'user',
                sortable: false,
                title: false,
                width: 150
            },
            log_type: {
                name: 'type',
                index: 'type',
                sortable: false,
                title: false,
                width: 120,
                formatter: function (v, o, r) {
                    return Zhibo.Util.formatter.log_type(v, o, r);
                }
            },
            log_descr: {
                name: "descr",
                index: 'descr',
                title: false,
                width: 450,
                sortable: false,
                formatter: function (v, o, r) {
                    return Zhibo.Util.formatter.log_descr(v, o, r);
                }
            },
            record_creator:{
                name: 'opUser',
                index: 'opUser',
                sortable: false,
                title: false,
                width: 150
            },
            record_start_time:{
                name: 'startTime',
                index: 'startTime',
                sortable: false,
                title: false,
                width: 150,
                align: 'center'
            },
            record_end_time:{
                name: 'endTime',
                index: 'endTime',
                sortable: false,
                title: false,
                width: 150,
                align: 'center'
            },
            record_id: {
                name: "id",
                index: 'id',
                width: 80,
                title: false,
                sortable: false,
                align: 'center'
            },
            record_operate:{
                width: 200,
                title: false,
                sortable: false,
                align: 'center',
                formatter: function (v, o, r) {
                    return Zhibo.Util.formatter.record_operate(v, o, r);
                }
            }
        },

        TABLE_LIST: {
            localReader: {
                id: "channel_id",
                root: "rows",
                page: "page",
                total: "total",
                records: "records"
            },
            multiselect: false,
            datatype: "local",
            height: 450,
            rowNum: 10,
            caption: "打点列表",
            colNames: ["id", "频道名称", "代号", "流地址", "服务器IP", "收费", "状态", "地区", "地区ID", "操作" ],
            colModel: ["channel_id", "channel_name", "channel_code", "channel_addr", "channel_ip", "freeType", "channel_status", "location", "loc_id", "operate2" ],
            pager: "#pager",
            onPaging: function (pgButton) {
                var retValue = Zhibo.Util.pageBeanPageHandler("list", "pager", Zhibo.Config.PageBean, pgButton);
                if (retValue != null) {
                    $("#list")[0].addJSONData(retValue)
                }
                return "stop";
            }
        },
        TABLE_IP: {
            localReader: {
                id: "id",
                root: "rows",
                page: "page",
                total: "total",
                records: "records"
            },
            multiselect: false,
            datatype: "local",
            height: 450,
            rowNum: 10,
            width: 600,
            colNames: ["ip", "地域", "操作"],
            colModel: ["ip", "region", "operate3"],
            pager: "#ip_pager",
            onPaging: function (pgButton) {
                var retValue = Zhibo.Util.pageBeanPageHandler("ipList", "ip_pager", Zhibo.Config.IpPageBean, pgButton);
                if (retValue != null) {
                    $("#ipList")[0].addJSONData(retValue)
                }
                return "stop";
            }
        },

        TABLE_LOG: {
            url: Zhibo.urlConfig.logListFilterUrl,
            loadBeforeSend: function (xhr, settings) {
                var auth = Ancestor.Util.getAuth("/vod/logList/filter");
                xhr.setRequestHeader('Sign', auth.sign);
                xhr.setRequestHeader("Time", auth.clientTime);
                xhr.setRequestHeader("From", auth.from);
                return true;
            },
            multiselect: false,
            loadtext: '加载中...',
            loadui: 'block',
            rowNum: 40,
            width: 875,
            mtype: "post",
            datatype: "local",
            prmNames: {
                page: "pageNo",
                rows: "pageSize"
            },
            colNames: ["ID", "操作时间", "人员", "动作", "备注"],
            colModel: ['log_id', "log_addTime", "log_user" , "log_type" , "log_descr"],
            pager: "#log_pager"
        },
        TABLE_RECORD: {
            url: Zhibo.urlConfig.recordListUrl,
            loadBeforeSend: function (xhr, settings) {
                var auth = Ancestor.Util.getAuth("/vod/vodRecord/getList");
                xhr.setRequestHeader('Sign', auth.sign);
                xhr.setRequestHeader("Time", auth.clientTime);
                xhr.setRequestHeader("From", auth.from);
                return true;
            },
            multiselect: false,
            loadtext: '加载中...',
            loadui: 'block',
            rowNum: 10,
            width: 875,
            mtype: "post",
            datatype: "local",
            prmNames: {
                page: "pageNo",
                rows: "pageSize"
            },
            colNames: ["ID", "开启收录时间", "停止收录时间", "创建人","添加时间","操作"],
            colModel: ['record_id', "record_start_time", "record_end_time" , "record_creator" , "log_addTime","record_operate"],
            pager: "#record_pager"
        },

        REGION_LIST: ['cq', 'sh', 'bj', 'tw'],
        REGION_CH_LIST: ['重庆', '上海', '北京', '台湾'],
        AUTH_REGION_CQ: false,
        AUTH_REGION_SH: false,
        AUTH_REGION_BJ: false,
        AUTH_REGION_TW: false,
        FUNC_EXTENT: ['enable', 'disable', 'delete_channel', 'modify_channel'],
        IP_LINK_AREA: {},
        AUTH_BASE: false,
        AUTH_SENIOR: false,
        monitorPlayer: null,
        PageBean: null,
        IpPageBean: null,
        ERROR_MSG: {
            CHANNEL_NAME_REG_ERROR: "频道名称格式不合法:名称由汉字、数字、字母组成",
            CHANNEL_CODE_REG_ERROR: '频道代码格式不合法:名称由字母、数字、"+ - _"组成',
            CHANNEL_ADDR_ILLEGAL_ERROR: "频道流地址格式不合法",
            CHANNEL_ADDR_PATTERN_ERROR: "流地址格式有误",
            CHANNEL_SERVER_EMPTY_ERROR: "频道服务器不能为空",
            RTMP_ERROR: "rtmp预览流地址格式不合法"
        },

        ENCODE_TYPE: ['CPU编码', 'GPU编码'],
        ENCODE_INDEX: ['GPU0', 'GPU1', 'GPU2', 'GPU3', 'GPU4'],
        ANSWER: ['否', '是'],
        ENCODE_PANOTYPE: ['', '否', '360度全景', '180度全景'],
        VOD_LOG_TYPE: {
            addElement: 101,
            delElement: 102,
            modifyElement: 103,
            includeElement: 104,
            stopElement: 105
        },
        FUNC_EXTENT_LOG: {
            'enable': 104,
            'disable': 105,
            'delete_channel': 102,
            'modify_channel': 103
        },
        WAIT_ADD_DATA: null,
        WHITE_LIST_WRAP_ONLINE:[
            {ip:"10.6.5.129"},
            {ip:"10.5.192.7"},
            {ip:"10.5.192.103"},
            {ip:"10.6.5.128"},
		    {ip: "10.5.192.8"}
        ],
        WHITE_LIST_WRAP_DEV:[
            {ip: "10.5.192.6",cn:"视频包装"},
			
        ]
    });
    Zhibo.Config.GREY_MODE = {
        containsObj: function (obj) {
            obj = $.extend({}, {ip: "", cn: ""}, obj);
            var checkArr = Zhibo.Config.WHITE_LIST_WRAP_ONLINE;
            if (auth.dev()) {
                checkArr = Zhibo.Config.WHITE_LIST_WRAP_DEV
            }
            var inRange = false;
            $.each(checkArr, function (i, element) {
                if(obj.ip == element.ip  ){
                    inRange = true;
                    return false;
                }
            })
            return inRange;
        }
    }
})